package com.lcz.dao.impl;

import com.lcz.bean.Grade;
import com.lcz.dao.DBUtils;
import com.lcz.dao.GradeDao;

import java.util.ArrayList;
import java.util.List;

public class GradeDaoImpl extends DBUtils implements GradeDao {
    @Override
    public List<Grade> getGrade() {
        List gs = new ArrayList();
        try {
            String sql = "select * from grade";
            resultSet  = query(sql, null);
            while(resultSet.next()){
                Grade grade = new Grade();
                grade.setGradeid(resultSet.getInt("gradeid"));
                grade.setGradename(resultSet.getString("gradename"));
                gs.add(grade);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            closeAll();
        }
        return gs;
    }
}
